<?php
namespace backend\controllers;

use backend\models\Project;
use backend\models\Config;
use common\components\BaseController;
use Yii;
use common\helps\tools;
use common\helps\code;
/**
 * Project controller
 */
class ConfigController extends BaseController
{

    public $modelClass = 'common\models\Config';
    public function init()
    {
        parent::init();
    }

    /**
     * 获取配置信息
     * @author hey_heyang(635870453@qq.com)
     * @return json
     */
    public  function  actionGetConfigInfo(){
        $model = new Config();
        $total_data = $model->getConfigInfo();
        return code::success($total_data);

    }



    /**
     * 编辑配置
     * @author hey_heyang(635870453@qq.com)
     * @return json
     */
    public  function  actionEditConfigInfo(){
        if($this->request->isPost) {
            $request =$this->request;
            $model = new Config();
            $params = $request->bodyParams;
            $model->load($params,'');
            if(!$model->validate()){
                $error = array_values($model->getErrors());
                return code::error('error',$error[0][0]);
            }
            $data=$model->editConfigInfo($params);
            if(!empty($data['error'])){
                return code::error('error',$data['error']);
            }else{
                return code::success();
            }
        }
    }





}

